home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / lists / mint / l_0399 / 191 < prev    next >
Encoding:
Internet Message Format  |  1994-08-27  |  6.3 KB

  1. From: Stephen Usher <steve@earth.ox.ac.uk>
  2. Subject: Re: Shared Libraries.
  3. Date: Wed, 31 Mar 1993 16:59:23 +0100 (BST)
  4. In-Reply-To: <9303311519.AA07587@netcom4.netcom.com> from "Eric R. Smith" at Mar 31, 93 07:19:14 am
  5. Mime-Version: 1.0
  6.  
  7. >>Hmm... why are you thinking about using such a mixed bag of formats? Why did
  8. >
  9. >? Both shared libraries and programs linked with them would be DRI object
  10. >files. The "GST long name symbol table" is a (minor and quite widely
  11. >supported, including by gcc) extension to the DRI symbol table format.
  12.  
  13. You mean standard TOS executable format?
  14.  
  15. This doesn't HAVE to be so as programs which use shared libraries will have
  16. to have a different magic number so as to stop them being run under the
  17. wrong environment.
  18.  
  19. >
  20. >Unix "ar" format wouldn't be suitable because a shared library isn't a
  21. >"library" in the sense of an ar file, but rather it's a single object
  22. >(more like an object file).
  23.  
  24. I understand this, I was just taking a format off the top of my head. The
  25. important thing, however, is that there is an index of modules (routines)
  26. which can be loaded individually, this index being loaded into the kernel's
  27. module lookup cache in the shared library mode lookup table.
  28.  
  29. If you have the whole library as one big object which has to be loaded in
  30. totallity then we might as well forget the whole idea of shared libraries!
  31.  
  32. >
  33. >>What you suggest seems fine for the 68000 based machines, but for the 68030
  34. >>based machines it seems a bit of a munge, why not give all processes on
  35. >>these machines the same virtual address space and map the shared library
  36. >>objects into that address space?
  37. >
  38. >I don't want to have to implement shared libraries twice. Obviously it
  39. >would be much easier to throw out 68000 support altogether, but I really
  40. >don't want to do that.
  41.  
  42. I understand this, that's why I suggested below a scheme which could be
  43. implemented on both architectures, as long as memory protections were sorted
  44. out (eg. making the shared library modules in memory global read-only).
  45. Later on, once MiNT has processes with their own virtual address space, the
  46. modules could be mapped in using the MMU.
  47.  
  48. >
  49. >>>------------------------------------------------------------------------------
  50. >>>| A's data |   FOO's data |   C's data  |  D's data  |  more of FOO's data   |
  51. >>>------------------------------------------------------------------------------
  52. >
  53. >>What happens if FOO needs A, B, C & D? This scheme also means that all the
  54. >>library modules will have to be loaded at load time instead at first call
  55. >>time (doesn't it?).
  56. >
  57. >If FOO needed library B, then it's data would have gone in between A's
  58. >data and C's (i.e. all of FOO's own data would have been contiguous).
  59. >
  60. >It is true that all the library modules for a program would have to be loaded
  61. >at program load time, rather than when the library is first called. I don't
  62. >think that this would generally be much of a problem; I doubt there are all
  63. >that many cases where a shared library is linked but never called at run time.
  64.  
  65. I'm sure there are quite a few cases, just look what scanf could pull in, it
  66. could pull in all sorts of floating point code when all you wanted was to
  67. parse a mixture of text and integers. (I know you could use an integer
  68. version, but this integer version will fill up your disk and should not be
  69. necessary.)
  70.  
  71. >
  72. >>How about an alternative....
  73. >
  74. >>(1) Have in the kernel a table of currently loaded modules, each with a
  75. >>    reference count.
  76. >>(2) Modules are loaded into an arbitary memory location with a read-only
  77. >>    copy of their initialised data space at the time of first reference
  78. >>    and a copy of the initialised data space is placed in the process'
  79. >>    shared lib data segment, which is separate from it's own data
  80. >>    segment. The total size of the shared library data segment is 64K on
  81. >>    the 68000 based machines and "unlimited" on 68030 based machines,
  82. >>    there is no limit imposed upon the normal data segment. Shared data
  83. >>    is accessed via an offset table.
  84. >>(3) Modules are deleted once the last program to use them exits, or
  85. >>    alternatively... The kernel table has a timer which is added to
  86. >>    every time a module is accessed. After n context switches, any
  87. >>    module which has not been accessed in that time could be deleted
  88. >>    from memory and a flag in the table set to say that the module is
  89. >>    active but not in memory. When the module is next accessed, it is
  90. >>    re-loaded, but the data space is not copied to the currently running
  91. >>    program. This would improve memory usage no end, especially if
  92. >>    modules were of a fixed size or a multiple of a fixed size, no
  93. >>    memory fragmentation! This would give a sort of virtual memory even
  94. >>    for 68000 based machines.
  95. >
  96. >(1) is obviously necessary for any shared library scheme :-).
  97. >(2) is reasonable, albeit slower (because of the extra indirection). The
  98. >shared library data segment would actually be limited in size to 64K items,
  99. >rather than 64K bytes (hmmm, actually 16K items, I guess, given 32 bit
  100. >offsets).
  101. >(3) is attractive, but I don't think it's workable. Or rather, it may not
  102. >be as useful as it seems. The module memory can't be re-used for anything
  103. >else (including program malloc requests), so there would be a win only
  104. >when the program is linked with a lot of large shared libraries which are
  105. >not all needed at the same time. This may be the case for X (:-)) but probably
  106. >not for very many other libraries; and given the number of MiNT specific
  107. >X implementations on the ST, this may not be much of a win :-(.
  108.  
  109. As with the example of scanf above, it could be a biggish win in programs
  110. which only use a subset of the libraries at any one time. It would also be a
  111. big win for programs waiting on I/O or something like that, as long as other
  112. programs aren't using the modules (routines) then they could be purged to
  113. load other modules in.
  114.  
  115. The memory freed by unloading modules could be used to load other modules
  116. in, it's a sort of paging mechanism which won't need a PMMU. The modules
  117. will all have to be position independent, however.
  118.  
  119. >
  120. >Thanks for your input, 
  121. >Eric
  122. >
  123.  
  124. I'm just throwing ideas into the wind!
  125.  
  126. Steve
  127.  
  128. -- 
  129. ---------------------------------------------------------------------------
  130. Computer Systems Administrator, Dept. of Earth Sciences, Oxford University.
  131. E-Mail: steve@uk.ac.ox.earth (JANET) steve@earth.ox.ac.uk (Internet).
  132. Tel:- Oxford (0865) 282110 (UK) or +44 865 282110 (International).
  133.